<template>
  <view class="profile-container">
    <view v-if="isLoggedIn" class="user-info">
      <image class="avatar" src="../../assets/avatar.png" mode="aspectFit" />
      <text class="username">用户名</text>
    </view>
    <view v-else class="login-prompt">
      <button class="login-button" @tap="goToLogin">去登录</button>
    </view>
  </view>
</template>

<script setup>
import Taro from '@tarojs/taro';
import { ref } from 'vue';

const isLoggedIn = ref(false); // 模拟登录状态

const goToLogin = () => {
  Taro.navigateTo({ url: '/pages/login/index' });
};

// onShow生命周期里检查登录状态
Taro.useDidShow(() => {
  const token = Taro.getStorageSync('token');
  isLoggedIn.value = !!token;
});

</script>

<style lang="scss">
@import './index.scss';
</style>
